var moneyFormat = function(money, len) {
	len = len || 2
	if (!money && money !== 0)
		return ''
	if (isNaN(+money))
		return ''
	if (money === 0 || money === '0')
		return '0.' + '0'.repeat(len)
	var arr = (money + '').split('.')
	var intStr = arr[0] ? arr[0] : 0
	var floatStr = arr[1] ? arr[1] : 0
	if (floatStr === 0) {
		floatStr = '0'.repeat(len)
	} else {
		floatStr = (+('0.' + floatStr)).toFixed(len).split('.')[1]
	}
	money = (intStr + '.' + floatStr).replace(/(\d{1,3})(?=(?:\d{3})+\.)/g, `$1,`);
	return money
}

var copyData = function(data) {
	var that = this
	uni.setClipboardData({
		data: '' + data,
		success: function() {
			uni.showToast({
				title: '复制成功',
				duration: 2000,
				icon: 'none'
			});
		},
		fail: function(err) {
			uni.showToast({
				title: '复制失败' + err,
				duration: 2000,
				icon: 'none'
			});
		}
	});
}


export default {
	moneyFormat: moneyFormat,
	copyData: copyData,
}